<template>
  <!--子任务-->
  <el-dialog
    :title="title"
    :visible.sync="ready"
    @close="closeTaskAdd"
    :destroy-on-close="true"
    style="height: 100%"
    width="70%">
    <iframe frameborder="0" :src="src" height="650px" width="100%"></iframe>
  </el-dialog>
</template>

<script>
export default {
  name: "taskAdd",
  inject:["root"],
  props: {
    add_url:{
      type: String,
      default:''
    },
    taskId: {
      type: String,
      default:''
    },
    start_at: {
      type: String,
      default:''
    },
    end_at: {
      type: String,
      default:''
    },
    curStaffCode: {
      type: String,
      default:''
    },
  },
  data() {
    return {
      timestamp:0,
      ready: true,
      src:'',
      title:''
    }
  },
  mounted() {
    if(this.root.websocket!==null){
      this.root.websocket.close()
      this.root.websocket = null
    }
    this.timestamp = new Date().getTime()
    let wsurl = "wss://"+window.location.hostname+"/"+this.$magicaltool.request.util.wrapCtxPath("ws/openapi/calendar/"+this.timestamp);
    // let wsurl = "wss://unicoder.zippro.cn/youyaboot-admin/ws/openapi/calendar/"+this.timestamp;
    console.log("wsurl",wsurl)
    this.root.websocket = this.root.ws(wsurl)
    this.src=this.add_url+`&task_id=${this.taskId}`+`&start_at=${this.start_at}`+`&end_at=${this.end_at}`+`&timestamp=${this.timestamp}`+`&curStaffCode=${this.curStaffCode}`
    // console.log(this.src)
    if(this.taskId){
      this.title='编辑任务'
    }else{
      this.title='添加任务'
    }
  },
  methods:{
    closeTaskAdd(){
      // this.ready = false
      this.root.setRenderRange()
    }
  }

}
</script>

<style scoped>
/deep/ .el-dialog {
  border-radius: 15px !important;
}
</style>
